package http_client

import (
	"io/ioutil"
	"net/http"
	"net/url"
)

func (u Urls) Request() {

}

func Start(urls Urls) Resp {
	result := Resp{}
	for _url, _info := range urls {
		http_resp := map[string]string{}
		params := url.Values{}
		for k, v := range _info {
			if k != "_method_" {
				params.Set(k, v)
			}
		}
		ask_url, _ := url.Parse(_url)
		ask_url.RawQuery = params.Encode()
		resp, err := http.Get(ask_url.String())
		if err != nil {
			println(err.Error())
			http_resp["error"] = err.Error()
		} else {
			content, _ := ioutil.ReadAll(resp.Body)
			http_resp["data"] = string(content)
		}
		result[_url] = http_resp
	}
	return result
}
